package day14.task;

import java.util.*;

public class MobilePhone implements Comparable<MobilePhone> {
    private String type;
    private Integer price;

    public MobilePhone(String type, int price) {
        this.type = type;
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    @Override
    public int compareTo(MobilePhone o) {
        return this.price.compareTo(o.getPrice());
    }

    @Override
    public String toString() {
        return
                "型号：" + type + ", 价格：" + price;
    }
}

class Main {
    public static void main(String[] args) {
        List<MobilePhone> link = new LinkedList<>();
        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            link.add(new MobilePhone(sc.next(), sc.nextInt()));
            // 创建一个LinkedList并使用集合进行初始化
        }
        System.out.println("排序前，链表中的数据：");
        for (MobilePhone m : link) {
            System.out.println(m);
        }

        Collections.sort(link);
        System.out.println("排序后，链表中的数据：");
        for (MobilePhone m : link) {
            System.out.println(m);
        }
        MobilePhone mobilePhone = new MobilePhone(sc.next(), sc.nextInt());
//        Collections.sort(list, Comparator.comparingDouble(Blog::getNumber).reversed());
        for (MobilePhone m : link) {
            if (m.getPrice()==mobilePhone.getPrice()) {
                System.out.println(mobilePhone.getType() + "与链表中的" + m.getType() + "价格相同");
                return;
            }
        }
         System.out.println("链表中的对象，没有一个与" + mobilePhone.getType() + "价格相同的");
    }


}
